"use strict";
import * as React from 'react';
const { View, Image, TouchableOpacity } = require('react-native');
const { connect } = require('react-redux');
const NavigationBar = require('react-native-navbar').default;
import { autoSize, commonProps, commonStyles } from "../../assets/styles/common";
import { SCREEN_WIDTH } from "../../constant";
import NavBackButton from "../../component/BackButton";
const { Actions } = require("react-native-router-flux");
import MyText from "../../component/MyText";
import { settingStyles } from "../../assets/styles/seetting";
import Colors from "../../assets/styles/Colors";
import Request from "../../utils/Request";
const appInfo = require('../../../app.json');
const { List } = require('antd-mobile');
class SettingPage extends React.Component {
    constructor(props, context) {
        super(props, context);
        this.logOut = () => {
            this.props.dispatch({
                type: 'auth/logOut'
            });
        };
        this.renderHeader = () => {
            return (<Image source={{ uri: Request.checkImageUrl(this.props.auth.profile.store_image) }} width={SCREEN_WIDTH} style={[{ height: autoSize(210), backgroundColor: 'red' }]}>
            </Image>);
        };
        this.state = {
            currentTab: 0,
        };
    }
    render() {
        if (!this.props.auth.isSignIn) {
            return null;
        }
        return (<View style={[commonStyles.container, commonStyles.relative]}>
                <NavigationBar {...commonProps.navBar} leftButton={<NavBackButton />} title={{ title: this.props.title, tintColor: '#fff' }}/>

                <List renderHeader={this.renderHeader}>
                    <List.Item extra={this.props.auth.profile.store_phone}>我的账号</List.Item>
                    <List.Item arrow='horizontal' onClick={Actions.findPwd}>修改密码</List.Item>
                    <List.Item onClick={Actions.findPwd} extra={appInfo.version}>版本</List.Item>
                </List>

                <View style={[commonStyles.absolute, settingStyles.btnContainer]}>
                    <TouchableOpacity style={[commonStyles.flex1, commonStyles.centerVH, settingStyles.btn]} onPress={this.logOut}>
                        <MyText color={Colors.White}>退出当前用户</MyText>
                    </TouchableOpacity>
                </View>
            </View>);
    }
}
export default connect(({ auth }) => ({ auth }))(SettingPage);
